<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>CSS 技巧 - 高度过渡问题</title>
    <style>
      .box {
        height: 0;
        overflow: hidden;
        background-color: green;
        color: white;
        transition: height 1s linear;
      }

      .box.show {
        height: 500px;
      }
    </style>
  </head>
  <body>
    <div>
      <button>切换</button>
    </div>
    <div class="box">
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Laboriosam
      voluptas, quam, quisquam at, id eligendi esse recusandae quidem officiis
      totam suscipit. Quis enim facere nihil illo sed. Animi, est dicta!
    </div>
    <script>
      const btn = document.querySelector("button");
      const box = document.querySelector(".box");
      btn.addEventListener("click", () => {
        box.classList.toggle("show");
      });
    </script>
  </body>
</html>
